<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="format-detection" content="telephone=no">
    <meta name="author" content="得闲技术 Team">
    <meta name="copyright" content="得闲技术">
    <title>添加部门 - Powered By 得闲技术</title>
    [#include "/admin/main/resources/list.ftl"/]
</head>
<body class="admin secondary">
<main>
    <div class="container-fluid">
        <form id="saveOrUpdateForm" class="ajax-form form-horizontal" action="save" method="post">
            <div class="panel panel-default">
                <div class="panel-heading">添加部门</div>
                <div class="panel-body padding-5">

                    <ul class="nav nav-tabs">
                        <li class="active">
                            <a href="#basic" data-toggle="tab">基本信息</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="basic" class="tab-pane active">

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label item-required"
                                        for="supplierId">上级部门:</label>
                                <div class="col-xs-9 col-sm-4">
                                    <select name="parentId" id="parentId" class="selectpicker form-control"
                                            data-live-search="true" required="required">
                                        <option value="0">顶级部门</option>
                                        [#list tree as department]
                                            <option value="${department.id}">
                                                [#if department.grade != 0]
                                                    [#list 1..department.grade as i]
                                                        &nbsp;&nbsp;
                                                    [/#list]
                                                [/#if]
                                                ${department.name}
                                            </option>
                                        [/#list]
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label item-required" for="name">名称:</label>
                                <div class="col-xs-9 col-sm-4">
                                    <input id="name" name="name" class="form-control" type="text" maxlength="20"
                                            required="required" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label item-required" for="order">排序:</label>
                                <div class="col-xs-9 col-sm-4" title="越小越靠前" data-toggle="tooltip">
                                    <input id="order" name="order" class="form-control" type="text" min="0"
                                            max="999999999" value="0"
                                            required="required" />
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-xs-3 col-sm-2 control-label">设置:</label>
                                <div class="col-xs-9 col-sm-4" data-toggle="tooltip">
                                    <div class="checkbox checkbox-inline">
                                        <input name="_isEnabled" type="hidden" value="false">
                                        <input id="isEnabled" name="isEnabled" type="checkbox" value="true"
                                                checked="checked">
                                        <label for="isEnabled">启用</label>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="panel-footer">
                    <div class="row">
                        <div class="col-xs-9 col-sm-10 col-xs-offset-3 col-sm-offset-2">
                            <button class="btn btn-primary" type="submit">确 定</button>
                            <button class="btn btn-default" type="button" data-action="back">返 回</button>
                        </div>
                    </div>
                </div>
            </div>
        </form>
    </div>
</main>
<script>
    $().ready(function () {

        var $saveOrUpdateForm = $("#saveOrUpdateForm");

        // 表单验证
        $saveOrUpdateForm.validate({
            rules: {},
            messages: {},
            submitHandler: function (form) {
                $(form).ajaxSubmit();
            }
        });
    });
</script>
</body>
</html>
